package com.hdey.service.chao.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdey.mapper.chao.WuziMapper;
import com.hdey.pojo.chao.Wuzi;
import com.hdey.service.chao.WuziService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service("wuziService")
@Transactional
public class WuziServiceImpl extends ServiceImpl<WuziMapper, Wuzi> implements WuziService {

    @Resource
    private WuziMapper wuziMapper;


    @Override
    public Page<Wuzi> searchPage(Integer current, Integer size, String cgName) {
        Page<Wuzi> page=new Page<>(current,size);
        LambdaQueryWrapper<Wuzi> wrapper=new LambdaQueryWrapper<>();
        wrapper.like(!StringUtils.isEmpty(cgName), Wuzi::getCgName,cgName);
        //wrapper.eq(wuzi.getDictionaryId()!=null,Wuzi::getDictionaryId,wuzi.getDictionaryId());
        wuziMapper.selectPage(page,wrapper);
        return page;
    }

    @Override
    public List<Wuzi> searchPage1() {
        List<Wuzi> list=wuziMapper.selectList(null);
        return list;
    }
}
